'use strict'

const path = require('path')

function resolve(dir) {
    return path.join(__dirname, dir)
}

const port = 8081

module.exports = {
    devServer: {
        host: '0.0.0.0',
        port: port,
        //open: true,
        proxy: {
            [process.env.VUE_APP_BASE_API]: {
                target: `http://localhost:8080`,
                pathRewrite: {
                    '^/dev-api': ''
                }
            }
        }
    },
    chainWebpack(config) {
        config.plugins.delete('preload') // TODO: need test
        config.plugins.delete('prefetch') // TODO: need test

        // set svg-sprite-loader
        config.module
          .rule('svg')
          .exclude.add(resolve('src/assets/icons'))
          .end()
        config.module
          .rule('icons')
          .test(/\.svg$/)
          .include.add(resolve('src/assets/icons'))
          .end()
          .use('svg-sprite-loader')
          .loader('svg-sprite-loader')
          .options({
            symbolId: 'icon-[name]'
          })
        .end()

    }
}
